'''
Created on Aug 6, 2009
@author: mjbommar
'''


def isOneOf(value, types):
    '''
    Check if value is one of the given types.
    This returns true if the number of isinstance True returns is greater than 0.
    '''
    if sum(map(lambda t: isinstance(value,t), types)) > 0:
        return True
    else:
        return False

def toNaturalType(value):
    '''
    Convert a string value to its natural Python type...
    Right now, this is done simply by passing through float,int,str.
    '''
    if type(value) == int or type(value) == float:
        return value
    
    if '.' in value:
        try:
            v = float(value)
        except:
            v = str(value)
    else:
        try:
            v = int(value)
        except:
            v = str(value)
    
    return v